package com.lyxmaster.lib.view;

import android.app.Application;
import android.content.Context;

import com.lyxmaster.lib.util.CrashHandler;
import com.lyxmaster.lib.xutils.x;
import com.lyxmaster.lib.zxing.activity.ZXingLibrary;

/**
 * Created by LYX on 2018/3/19.
 */

public class MyApplication extends Application {
    // 在application的onCreate中初始化

    private static Context instance;

    public static Context getContext()
    {
        return instance;
    }

    @Override
    public void onCreate() {
        super.onCreate();
        x.Ext.init(this);

        instance = getApplicationContext();

        CrashHandler appException = CrashHandler.getInstance();
        appException.init(instance);
        ZXingLibrary.initDisplayOpinion(this);  //二维码初始化
//        x.Ext.setDebug(BuildConfig.DEBUG); // 是否输出debug日志, 开启debug会影响性能.
    }

    private static volatile MyApplication myApplication;

    public static MyApplication getInstance() {

        if (myApplication == null) {

            synchronized (MyApplication.class) {

                if (myApplication == null) {

                    myApplication = new MyApplication();

                }
            }
        }

        return myApplication;

    }
}
